package com.kfyang.manualgear.struct;

import java.util.List;

/**
 * 分页结果实现类
 * @param <T> 结果类型
 */
public class PageResultImpl<T> implements PageResult<T> {

    private final int size;
    private final int total;
    private final List<T> result;

    public PageResultImpl(int size, int total, List<T> result) {
        this.size = size;
        this.total = total;
        this.result = result;
    }

    @Override
    public int getTotalPages() {
        return (total + size - 1) / size; // 向上取整
    }

    @Override
    public int getTotalElements() {
        return total;
    }

    @Override
    public List<T> getResult() {
        return result;
    }
}
